#!/usr/bin/perl
#Programmer: Rory Carmichael
#Purpose: Sort a fasta file so that stats may some day be collected from it
#Usage: sort_fasta.pl <fasta_file>

open(OF, ">sf.tmp");
while (my $line = <>) {
	chomp $line;
	if ($line =~ /^>/) {
		$line .= "^" . <>;
		print OF $line;
	} else {
		print STDERR "CRAP, fasta file wasn't 2lined\n";
		exit 1;
	}
}
close(OF);
print `sort sf.tmp | awk -F^ '{print \$1\"\\n\"\$2}'`; 
`rm sf.tmp`;
